home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games Extra 1996 September
/
Amiga Games Extra CD-ROM 9-1996.iso
/
userbox
/
publicdomain
/
wbstars
/
source
/
wbstars_temp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-10
|
5KB
|
360 lines
/* $VER: WBStars_temp.c 1.12 (09.07.1996)
* This file contains empty template routines that
* the IDCMP handler will call uppon. Fill out these
* routines with your code or use them as a reference
* to create your program.
*/
#include "WBStars_include.h"
#include "WBStars_protos.h"
#include "WBStars_gui.h"
char colnums[256];
int azincClicked( void )
{
/* routine when gadget "+" is clicked. */
az2=(az2+1)%360;
GT_SetGadgetAttrs(WBStarsGadgets[GD_azimut2],WBStarsWnd,NULL,GTIN_Number,az2,TAG_DONE);
return TRUE;
}
int hedecClicked( void )
{
/* routine when gadget "-" is clicked. */
if(he2>-90)
{
he2=he2-1;
GT_SetGadgetAttrs(WBStarsGadgets[GD_height2],WBStarsWnd,NULL,GTIN_Number,he2,TAG_DONE);
}
return TRUE;
}
int heincClicked( void )
{
/* routine when gadget "+" is clicked. */
if(he2<90)
{
he2=he2+1;
GT_SetGadgetAttrs(WBStarsGadgets[GD_height2],WBStarsWnd,NULL,GTIN_Number,he2,TAG_DONE);
}
return TRUE;
}
int azdecClicked( void )
{
/* routine when gadget "-" is clicked. */
az2=(az2+359)%360;
GT_SetGadgetAttrs(WBStarsGadgets[GD_azimut2],WBStarsWnd,NULL,GTIN_Number,az2,TAG_DONE);
return TRUE;
}
int courseClicked( void )
{
/* routine when gadget "OK" is clicked. */
ClearIfOk();
az=az2=GetNumber( WBStarsGadgets[GD_azimut2] );
he=he2=GetNumber( WBStarsGadgets[GD_height2] );
GT_SetGadgetAttrs(WBStarsGadgets[GD_azimut],WBStarsWnd,NULL,GTNM_Number,az,TAG_DONE);
GT_SetGadgetAttrs(WBStarsGadgets[GD_height],WBStarsWnd,NULL,GTNM_Number,he,TAG_DONE);
NewStars();
return TRUE;
}
int warpClicked( void )
{
/* routine when gadget "Warp" is clicked. */
warpf=WBStarsMsg.Code;
ClearIfOk();
NewStars();
return TRUE;
}
int mode_winClicked( void )
{
/* routine when gadget "Use Window" is clicked. */
ClearIfOk();
if(mode==MODE_WIN)
{
mode=MODE_SCREEN;
}
else
{
mode=MODE_WIN;
}
if(GetWindow()==FALSE)
{
WinWait();
}
return TRUE;
}
int priClicked( void )
{
/* routine when gadget "Pri" is clicked. */
wbs_pri=WBStarsMsg.Code;
SetTaskPri(FindTask(0),wbs_pri);
return TRUE;
}
int saveClicked( void )
{
/* routine when gadget "Save" is clicked. */
/* BPTR fh;
long pref[263];
short i;
pref[0]=(long)wbs_pri;
pref[1]=(long)mode;
pref[2]=(long)anzstars;
pref[3]=(long)warpf;
pref[4]=(long)az;
pref[5]=(long)he;
pref[6]=(long)bgpen;
for(i=0;i<npen+1;i++)
{
pref[i+7]=(long)PEN[i];
}
pref[i+7]=(long)-1;
if(fh=Open("ENV:WBStars.prefs",MODE_NEWFILE))
{
Write(fh,&pref[0],4*(i+8));
Close(fh);
}
if(fh=Open("ENVARC:WBStars.prefs",MODE_NEWFILE))
{
Write(fh,&pref[0],4*(i+8));
Close(fh);
}
*/
return TRUE;
}
int resetClicked( void )
{
/* routine when gadget "Reset" is clicked. */
if(status==ACTIVE)
{
ClearIfOk();
Screen=NULL;
wnd=NULL;
}
az=AZI;
he=HEI;
az2=AZI;
he2=HEI;
wbs_pri=PRI;
mode=STRTMODE;
anzstars=MAXSTARS;
warpf=WRP;
bgpen=BACKPEN;
PEN[0]=2;
npen=NPEN;
LoadPrefs();
SetTaskPri(FindTask(0),wbs_pri);
SetGadgets();
if(status==ACTIVE)
{
if(GetWindow()==FALSE)
{
WinWait();
}
}
return TRUE;
}
int removeClicked( void )
{
/* routine when gadget "Remove" is clicked. */
idcmp=IDC_QUIT;
return TRUE;
}
int statusClicked( void )
{
/* routine when gadget "" is clicked. */
if( WBStarsMsg.Code==0 )
{
status=ACTIVE;
}
else
{
ClearIfOk();
status=INACTIVE;
Screen=NULL;
wnd=NULL;
}
return TRUE;
}
int bg_setClicked( void )
{
/* routine when gadget "BG" is clicked. */
ClearIfOk();
bgpen=GetNumber( WBStarsGadgets[GD_bg_set] );
return TRUE;
}
int bg_tryClicked( void )
{
/* routine when gadget "try" is clicked. */
/* short i;
char testcolor[256];
char numcolors=0;
short minum;
ClearIfOk();
for(i=0;i<anzcolors;i++)
{
testcolor[i]=0;
}
for(i=0;i<min(maxx,maxy);i++)
{
testcolor[ReadPixel(RastP,i,i)]++;
}
while(numcolors<anzcolors)
{
for(i=anzcolors;i>0;i--);
{
minum=0;
if(testcolor[i-1]>-1)
{
if(testcolor[i-1]>0)
{
if(minum==0)
{
minum=testcolor[i-1];
}
else
{
minum=min(minum,testcolor[i-1]);
}
}
else
{
testcolor[i-1]=-1;
numcolors++;
colnums[anzcolors-numcolors]=i;
}
}
}
if(minum)
{
for(i=0;i<anzcolors;i++)
{
testcolor[i]-=minum;
}
}
}
*/
return TRUE;
}
int bg_nextClicked( void )
{
/* routine when gadget "next" is clicked. */
ClearIfOk();
bgpen=( GetNumber( WBStarsGadgets[GD_bg_set] ) +1)%anzcolors;
GT_SetGadgetAttrs(WBStarsGadgets[GD_bg_set],WBStarsWnd,NULL,GTIN_Number,bgpen,TAG_DONE);
return TRUE;
}
int height2Clicked( void )
{
/* routine when gadget "" is clicked. */
short he3;
he3=GetNumber( WBStarsGadgets[GD_height2] );
if( (he3>-91)&&(he3<91) )
{
he2=he3;
}
else
{
GT_SetGadgetAttrs(WBStarsGadgets[GD_height2],WBStarsWnd,NULL,GTIN_Number,he2,TAG_DONE);
}
return TRUE;
}
int azimut2Clicked( void )
{
/* routine when gadget "" is clicked. */
short az3;
az3=GetNumber( WBStarsGadgets[GD_azimut2] );
if( (az3>-180)&&(az3<361) )
{
az2=(az3+360)%360;
}
GT_SetGadgetAttrs(WBStarsGadgets[GD_azimut2],WBStarsWnd,NULL,GTIN_Number,az2,TAG_DONE);
return TRUE;
}
int starsClicked( void )
{
/* routine when gadget "Stars" is clicked. */
ClearIfOk();
anzstars=WBStarsMsg.Code;
NewStars();
return TRUE;
}
int WBStarsCloseWindow( void )
{
/* routine for "IDCMP_CLOSEWINDOW". */
idcmp=IDC_HIDE;
return TRUE;
}